package com.fanqie.springboot2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author php
 */
@SpringBootApplication
@RestController
public class SpringbootRedisApplication {
    /**
     * 注入StringRedisTemplate
     */
    private final StringRedisTemplate stringRedisTemplate;

    @Autowired
    public SpringbootRedisApplication(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringbootRedisApplication.class, args);
    }


    @GetMapping("/name")
    public String  get(){
        this.stringRedisTemplate.opsForValue().set("name","英雄");
        return this.stringRedisTemplate.opsForValue().get("name");
    }
}
